<template>
  <swiper>
      <swiper-item v-for="item in banners" :key="item.index">
        <a :href="item.link">
          <img :src="item.image" @load="imgload">
        </a>
      </swiper-item>
    </swiper>
</template>

<script>
import {Swiper,SwiperItem} from '@/components/common/swiper'
export default {
  props: {
    banners:{
      type: Array,
      default(){
        return []
      }
    }
  },
  components: {
    Swiper,
    SwiperItem
  },
  data() {
    return {
      isload: true
    }
  },
  methods: {
    //判断轮播图是否加载出来
    imgload() {
      if(this.isload){
        this.$emit('imgload');
        this.isload = !this.isload; //只允许调用一次
      }
    }
  }
}
</script>